import React from 'react'
import Connect from '../connect'
import { Input } from 'antd'

const Brother = ({ Say, YTBrother }) => {
  console.log('哥哥RUN')
  const putChange = (e) => {
    Say(e.target.value)
  }

  return (
    <section className="b">
      <div>
        <p>弟弟说了: {YTBrother}</p>
        <p>
          告诉弟弟：
          <Input onChange={putChange} />
        </p>
      </div>
    </section>
  )
}

const mapStateToProps = (state) => {
  return {
    YTBrother: state.user.YoungerToBrother,
  }
}

const mapDispatchToProps = (dispatch) => {
  return {
    // 发送给弟弟的话
    Say: (BrotherToYounger) => {
      dispatch({
        type: 'updateUser',
        name: 'userReducer',
        payload: {
          BrotherToYounger,
        },
      })
    },
  }
}

export default Connect(mapStateToProps, mapDispatchToProps)(Brother)
